const arr = [1, [2, [3, 4]]];
// console.log(flatDeep(arr, Infinity)); // [1, 2, 3, 4]
// console.log(flatDeep(arr, 0)); // [1, 2, 3, 4]

const flatten = (arr) => {
    return arr.toString().split(',').map((item) => +item)
}
console.log(flatten(arr));
console.log(arr);

['1', '2', '3', '4'].map()
console.log();